package com.sdk;


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;

import com.sdk.widget.WaveView;

import payment.mobilepos.unionpay.com.R;


/**
 * <pre>
 *     author : liuso
 *     e-mail : xxx@xx
 *     time   : 2018/12/18
 *     desc   :
 *     version: 1.0
 * </pre>
 */
public class SpeechDialog extends Dialog {


    private TextView mBottomTv;
    private TextView mTopTv;
    private WaveView mWaveView;
    private TextView mCenterTv;

    public SpeechDialog(@NonNull Context context) {
        super(context);
    }

    public SpeechDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pop_speech);
        mBottomTv = findViewById(R.id.pop_bottom_tv);
        mTopTv = findViewById(R.id.pop_top_tv);
        mWaveView = findViewById(R.id.pop_wave);
        mCenterTv = findViewById(R.id.pop_center_tv);
    }

    public void stopAndStartRender(boolean enable) {
        if (enable) {
            mWaveView.startRender();
            mCenterTv.setVisibility(View.GONE);
        } else {
            mWaveView.stopRender();
        }
    }

    public WaveView getWaveView() {
        return mWaveView;
    }
    public void showError(String error){
        stopAndStartRender(false);
        mCenterTv.setVisibility(View.VISIBLE);
        mCenterTv.setText(error);
    }
    public View getClickView(){
        return mCenterTv;
    }
}
